{% extends 'base.twig' %}
{% block style %}
    <style>
        .table thead tr th{
            height:30px; line-height: 30px; text-align: center;}
        .table tbody tr td{
            height:30px; line-height: 30px; text-align: center;}
    </style>
    <link href="template/plugins/pnotify/css/pnotify.custom.css" rel="stylesheet" type="text/css">
    <script src="template/plugins/pnotify/js/pnotify.custom.js" type="text/javascript"></script>
{% endblock %}
{% block content %}
<section id="main-content">
    <section class="wrapper">
        <div class="row mt">
            <div class="col-lg-12">
                <div class="content-panel">
                    <h4><i class="fa fa-directory"></i> 主页列表</h4>
                    <section class="filter bg-warning" style="padding: 10px 0;">
                            <form action="site.php" method="GET">
                                <div class="row">
                                    <div class="col-sm-3">
                                        <div class="input-group">
                                            <span class="input-group-addon">域名</span>
                                            <input type="hidden" class="form-control" name="act" value="search">
                                            <input type="text" class="form-control" name="domain" value="{{ filter.domain }}">
                                        </div>
                                    </div>
                                    <button type="submit" class="btn btn-default"><i class="fa fa-search"></i> 搜索 </button>
                                </div>
                            </form>
                    </section>
                    <section id="unseen">
                        <table class="table table-bordered ">
                            <thead>
                            <tr>
                                <th>域名</th>
                                <th>标题</th>
                                <th>SEO标题</th>
                                <th>SEO描述</th>
                                <th>语言</th>
                                <th>是否已设置主页</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {% for d in domainList %}
                                <tr {% if d.is_del == 1 %} class="bg-danger" {% endif %}>
                                    <td>{{ d.domain }}</td>
                                    <td>{{ d.title  }}</td>
                                    <td>{{ d.seo_title }}</td>
                                    <td>{{ d.seo_description }}</td>
                                    <td>
                                        {% if d.lang == 'TW' %} 繁体中文 {% endif %}
                                        {% if d.lang == 'EN' %} 英语 {% endif %}
                                        {% if d.lang == 'CN' %} 简体中文 {% endif %}
                                        {% if d.lang == 'JP' %} 日语 {% endif %}
                                        {% if d.lang == 'AR' %} 阿拉伯语 {% endif %}
                                        {% if d.lang == 'VNM' %} 越南语 {% endif %}
                                         {% if d.lang == 'THA' %} 泰语 {% endif %}
                                    </td>
                                    <td>
                                        {% if d.title is null %}
                                            否
                                        {% else %}
                                            是
                                        {% endif %}
                                    </td>
                                    <td>
                                        {% if d.is_del == 1 %}
                                            <a class="btn btn-success" onclick="delsite('{{ d.domain }}',0);"><i class="fa fa-edit"></i> 恢复 </a>
                                        {% else %}
                                            <a class="btn btn-primary" href="site.php?act=edit&domain={{ d.domain }}"><i class="fa fa-edit"></i> 编辑</a>
                                            {% if d.title is not null %}
                                                <a class="btn btn-danger"  onclick="delsite('{{ d.domain }}',1);"><i class="fa fa-times"></i> 删除 </a>
                                            {% endif %}
                                        {% endif %}
                                    </td>
                                </tr>
                            {% endfor %}
                            </tbody>

                        </table>

                        <div class="text-center">
                            {{ pageHtml|raw }}
                        </div>
                    </section>
                </div>
            </div>
        </div>
    </section>
</section>
    <script type="text/javascript">
        highlight_subnav('site.php?');
        function delsite(domain,is_del) {
            var url = 'site.php?' ;
            var json = {domain:domain,is_del:is_del,act:"delete"};
            if(confirm('确认进行此操作吗？'))
            {
                $.ajax({
                    url : url,
                    data : json,
                    type : "post",
                    dataType:"json",
                    success : function(data) {
                        if(data.ret){
                            location.reload()
                        }
                        else{
                            new PNotify({
                                title: '错误！！',
                                text: data.msg,
                                type: 'error',
                                addclass: 'stack-bar-top'
                            });
                        }
                    },
                    error:function(XMLHttpRequest, textStatus, errorThrown){
                        alert(errorThrown);
                    }
                });
            }
        }
    </script>
{% endblock %}
